/**
 * 作者: heweiping
 * 日期: 2025-04-10 15:46:50
 * 备注: 用户公共活动信息表
 */
package com.motu.monstercity.server.game.userdata;

import com.motu.vertx.module.utility.model.BaseModel;
import com.motu.vertx.module.utility.model.Model;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

public class UserCommonActModel extends BaseModel implements Model {
    public static final String LISTKEY = "";
    public static final int REDIS_EXPIRE_TIME = 0;// redis过期时间
    public static final int UPDATE_DB_TYPE = UPDATE_DB_TYPE_QUEUE;// 数据入库类型 队列入库
    public static final boolean ORDER_LIST = false;// 是否需要额外的有序列表

    protected long id; // 玩家id
    protected String hundredDrawGet = ""; // 百抽活动领取记录
    protected String heroLoginGet = ""; // 每日登录送英雄
    protected String chargeHundredDrawGet = ""; // 充值百抽
    protected String hundredCharge = ""; // 百抽充值天数

    public void reset() {
    }

    protected String getKey() {
        return "UserCommonAct." + id;
    }

    protected String getListKey() {
        return null;
    }

    protected String getListItemKey() {
        return null;
    }

    public void doCreate() {
        setTableId();
        insert();
    }

    public void setTableId() {
        putId(incrTableId("user_common_act"));
    }

    public JsonObject insert() {
        return super.insert(getKey(), id, REDIS_EXPIRE_TIME, UPDATE_DB_TYPE, LISTKEY, getListKey(), getListItemKey(), ORDER_LIST);
    }

    public void delete() {
        super.delete(getKey(), id, UPDATE_DB_TYPE, id, LISTKEY, getListKey(), getListItemKey(), ORDER_LIST);
    }

    /**
     * 根据入库类型更新
     */
    public JsonObject update() {
        return super.update(getKey(), id, REDIS_EXPIRE_TIME, UPDATE_DB_TYPE, id, getAllObj(), LISTKEY, getListKey(), getListItemKey());
    }

    /**
     * 实时入库
     */
    public JsonObject updateNow() {
        return super.update(getKey(), id, REDIS_EXPIRE_TIME, UPDATE_DB_TYPE_NOW, 0, getAllObj(), LISTKEY, getListKey(), getListItemKey());
    }

    /**
     * 实时入队列
     */
    public JsonObject updateQueueNow() {
        return super.update(getKey(), id, REDIS_EXPIRE_TIME, UPDATE_DB_TYPE, 0, getAllObj(), LISTKEY, getListKey(), getListItemKey());
    }

    public JsonObject getAllObj(){
        JsonObject obj = new JsonObject();
        obj.put("id", id); // 玩家id
        obj.put("hundredDrawGet", hundredDrawGet); // 百抽活动领取记录
        obj.put("heroLoginGet", heroLoginGet); // 每日登录送英雄
        obj.put("chargeHundredDrawGet", chargeHundredDrawGet); // 充值百抽
        obj.put("hundredCharge", hundredCharge); // 百抽充值天数
        return obj;
    }

    public long getId() {
        return id;
    }

    public void putId(long id) {
        if (this.id != id) {
            this.id = id;
            updateRedisHashField(getKey(), "id", this.id);
        }
    }

    public void addId(long value) {
        this.id += value;
        updateRedisHashField(getKey(), "id", this.id);
    }

    public JsonArray getHundredDrawGetArray() {
        if (this.hundredDrawGet != null && this.hundredDrawGet.length() > 0) {
            return new JsonArray(this.hundredDrawGet);
        } else {
            return new JsonArray();
        }
    }

    public String getHundredDrawGet() {
        return hundredDrawGet;
    }

    public void putHundredDrawGet(String hundredDrawGet) {
        if (!this.hundredDrawGet.equals(hundredDrawGet)) {
            this.hundredDrawGet = hundredDrawGet;
            updateRedisHashField(getKey(), "hundredDrawGet", this.hundredDrawGet);
        }
    }

    public JsonArray getHeroLoginGetArray() {
        if (this.heroLoginGet != null && this.heroLoginGet.length() > 0) {
            return new JsonArray(this.heroLoginGet);
        } else {
            return new JsonArray();
        }
    }

    public String getHeroLoginGet() {
        return heroLoginGet;
    }

    public void putHeroLoginGet(String heroLoginGet) {
        if (!this.heroLoginGet.equals(heroLoginGet)) {
            this.heroLoginGet = heroLoginGet;
            updateRedisHashField(getKey(), "heroLoginGet", this.heroLoginGet);
        }
    }

    public JsonArray getChargeHundredDrawGetArray() {
        if (this.chargeHundredDrawGet != null && this.chargeHundredDrawGet.length() > 0) {
            return new JsonArray(this.chargeHundredDrawGet);
        } else {
            return new JsonArray();
        }
    }

    public String getChargeHundredDrawGet() {
        return chargeHundredDrawGet;
    }

    public void putChargeHundredDrawGet(String chargeHundredDrawGet) {
        if (!this.chargeHundredDrawGet.equals(chargeHundredDrawGet)) {
            this.chargeHundredDrawGet = chargeHundredDrawGet;
            updateRedisHashField(getKey(), "chargeHundredDrawGet", this.chargeHundredDrawGet);
        }
    }

    public JsonArray getHundredChargeArray() {
        if (this.hundredCharge != null && this.hundredCharge.length() > 0) {
            return new JsonArray(this.hundredCharge);
        } else {
            return new JsonArray();
        }
    }

    public String getHundredCharge() {
        return hundredCharge;
    }

    public void putHundredCharge(String hundredCharge) {
        if (!this.hundredCharge.equals(hundredCharge)) {
            this.hundredCharge = hundredCharge;
            updateRedisHashField(getKey(), "hundredCharge", this.hundredCharge);
        }
    }

}